﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class AdminCMS_UpdatePass : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { 
            //获取旧密码
            oldpass = DataEntity.Common.ExecuteScalar<string>("select adm_LoginPass from tab_Admin where adm_ID = @adm_ID", new string[] { "@adm_ID" }, new object[] { UIMethod.GetUserID() });            
        }
    }

    string oldpass
    {
        set { ViewState["oldpass"] = value; }
        get { return (ViewState["oldpass"] == null) ? string.Empty : Convert.ToString(ViewState["oldpass"]); }
    }

    protected void btn_submit_Click(object sender, EventArgs e)
    {
        string op = oldpass;
        //检查旧密码
        if (UIMethod.GetMD5(txt_oldpass.Text) != op) { UIMethod.Alert("旧密码不正确!"); return; }
        //确认新密码
        if (txt_newpass.Text.Trim() != txt_agent.Text.Trim()) { UIMethod.Alert("确认密码不一致!"); return; }

        //更新
        DataEntity.tab_Admin.UpdatePass(UIMethod.GetUserID(), UIMethod.GetMD5(txt_newpass.Text.Trim()));
        
        UIMethod.Alert("操作成功");
    }
}
